package com.pason.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(urlPatterns="/hello")
public class HelloServlet extends HttpServlet{
	
	private final String SESSION_KEY = "session";

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//Nothing
	}
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		System.out.println("================= HelloServlet START====================");
		if(request.getSession().getAttribute(SESSION_KEY) != null){
			System.out.println("=========SESSION OK OK OK==========");
		} else {
			System.out.println("=========SESSION NULL NULL NULL==========");
			request.getSession().setAttribute(SESSION_KEY, new String("hello session"));
			System.out.println(request.getSession().getAttribute(SESSION_KEY));
		}
		System.out.println("================= HelloServlet END====================");
	}
}

